package com.example.chenjun.myapplication.fragment;

import android.database.DataSetObserver;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ListAdapter;
import android.widget.ListView;

import com.example.chenjun.myapplication.R;
import com.example.chenjun.myapplication.adapter.CookExpandListAdapter;
import com.example.chenjun.myapplication.bean.LabelBean;
import com.example.chenjun.myapplication.mvp.MVPFragment;
import com.example.chenjun.myapplication.mvp.contract.LabelsContract;
import com.example.chenjun.myapplication.mvp.model.CookModel;
import com.example.chenjun.myapplication.mvp.presenter.LabelsPresenter;

import java.util.List;

public class HomeFragment extends MVPFragment<LabelsPresenter, CookModel> implements LabelsContract.LabelsView {

    private CookExpandListAdapter mAdapter;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.app_fragment_home, container, false);
        ExpandableListView lv = view.findViewById(R.id.expanded_menu);
        mAdapter = new CookExpandListAdapter();
        lv.setAdapter(mAdapter);
        mPresenter.getCookLabel();
        return view;
    }

    @Override
    public void getLabelsSuccess(List<LabelBean> list) {
        mAdapter.setData(list);
    }

    @Override
    public void getLabelsFailed(Exception e) {

    }
}
